import E from 'wangeditor' 

const { $, BtnMenu, DropListMenu, PanelMenu, DropList, Panel, Tooltip } = E
export class dropMenu extends DropListMenu {
    constructor(editor){
        const $elem = $('<div class="w-e-menu" data-title="下拉选择字段">字段配置</div>')
        // droplist 配置
        var data = []
        var arr=[]
        batchTree({year:2021}).then(res=>{
            if(res.data.code==200){
                    data =res.data.data
                    data.forEach(item => {
                        let str = `<p>${item.name}</p>`
                        console.log(str)
                        arr.push({
                            $elem:$(str),
                            value:item.name
                        })
                    });
            }
        })
        console.log(arr)
        const dropListConf = {
            width: 120,
            title: '设置插入字段',
            type: 'list',
            list: arr,
            // droplist 每个 item 的点击事件
            clickHandler: (value) => {
                // value 参数即 dropListConf.list 中配置的 value
                editor.cmd.do("insertHTML", value);
            },
        }
        super($elem, editor, dropListConf)
    }
}